﻿#pragma once
#include "AstType.h"

class AutoType : public AstType {
public:
	AutoType() {
		name = "auto";				// 命名
	}

	virtual SiTypeId type() { return _deductive ? _deductive->type() : AutoTyId;  }
	static bool isAuto(AstType* type) { return !type || dynamic_cast<AutoType*>(type); }
	void setDeductive(AstType* type) { _deductive = type;  }
public:
	virtual llvm::Type* llvmType(llvm::LLVMContext& context) {
		if (!_deductive) throw std::runtime_error("Unknown auto type.");
		return _deductive->llvmType(context);
	}
protected:
	AstType* _deductive = nullptr;
};
